<?php
require_once 'init.inc';
$title = 'Корзина';

$basket = new Basket;

if ($par->exist('productIds')) 
{
	$productIds = $par->get('productIds');
	$optionIds = $par->get('optionIds');
	$amounts = $par->get('amounts');
	
	$basket->purge();
	
	for ($i=0; $i<count($productIds); ++$i) 
	{
		if ($par->exist("order_$i")) 
		{
			$basket->add($productIds[$i], $optionIds[$i], $amounts[$i]);
		}
	}
}

if ($par->exist('proceed')) 
{
	header('Location: buy.php');
}

$products = $basket->toArray();

assignTemplateVars('title','products','basket');
display('basket');
?>
